import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 重定向
  {
    path: '/',
    redirect: '/layout'
  },
  // 登录页面
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  // 搜索页面
  {
    path: '/search',
    component: () => import('@/views/Search')
  },
  // 搜索结果页
  {
    path: '/search/:keywords',
    component: () => import('@/views/SearchResult')
  },
  // 文章详情
  {
    path: '/article_detail',
    component: () => import('@/views/ArticleDetail')
  },
  // 用户编辑资料
  {
    path: '/user_edit',
    component: () => import('@/views/User/UserEdit')
  },
  // 小思同学页面
  {
    path: '/chat',
    component: () => import('@/views/User/Chat')
  },

  // 布局页面
  {
    path: '/layout',
    redirect: '/layout/home',
    component: () => import('@/views/Layout'),
    children: [
      {
        path: 'home',
        meta: { // 路由元信息(路由信息保存更多信息)
          scrollT: 0 // 首页滚动的距离
        },
        component: () => import('@/views/Home')
      },
      {
        path: 'user',
        component: () => import('@/views/User')
      }
    ]
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router
